package com.navinfo.opentsp.platform.computing.service.huashen;

import com.googlecode.protobuf.format.JsonFormat;
import com.navinfo.opentsp.platform.computing.anno.RoutingProtocol;
import com.navinfo.opentsp.platform.computing.enums.ProtocolEnum;
import com.navinfo.opentsp.platform.computing.enums.YardEnum;
import com.navinfo.opentsp.platform.computing.service.IProtocolParseService;
import com.navinfo.opentsp.platform.location.protocol.common.LCFaultInfo;
import org.apache.flume.Event;

@RoutingProtocol(yard = YardEnum.HUASHEN, protocolType = ProtocolEnum.FAULT_DATA)
public class Fault0F3AHuaShenService implements IProtocolParseService {

    @Override
    public String parseProtocol(Event event) {

        try{
            LCFaultInfo.FaultInfo message = LCFaultInfo.FaultInfo.parseFrom(event.getBody());
            return JsonFormat.printToString(message);
        } catch(Exception e) {
            throw new RuntimeException(e);
        }
    }
}
